﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using NUnit.Framework;

namespace ReducaoPena.UnitTest {
	[TestFixture]
	public class ValidaTarefasDados {

		#region Valida Codigo
		[Test]
		public void Valida_Tarefa_Codigo_Zero() {

			try {
				Tarefa t = new Tarefa(0, 10, "Seg", "08:00", "23:00");
				Assert.Fail();
			} catch (ArgumentException ae) {
				Assert.AreEqual(ae.Message, "Código de tarefa inválido");
			}
		}

		[Test]
		public void Valida_Tarefa_Codigo_DezMileUm() {

			try {
				Tarefa t = new Tarefa(10001, 10, "Seg", "08:00", "23:00");
				Assert.Fail();
			} catch (ArgumentException ae) {
				Assert.AreEqual(ae.Message, "Código de tarefa inválido");
			}
		}

		[Test]
		public void Valida_Tarefa_Codigo_Um() {

			try {
				Tarefa t = new Tarefa(1, 10, "Seg", "08:00", "23:00");
				Assert.AreEqual(1, t.Codigo);
			} catch (ArgumentException ae) {
				Assert.Fail();
			}
		}

		[Test]
		public void Valida_Tarefa_Codigo_DezMil() {

			try {
				Tarefa t = new Tarefa(10000, 10, "Seg", "08:00", "23:00");
				Assert.AreEqual(10000, t.Codigo);
			} catch (ArgumentException ae) {
				Assert.Fail();
			}
		}
		#endregion

		#region Valida Pontos
		[Test]
		public void Valida_Tarefa_Pontos_Zero() {

			try {
				Tarefa t = new Tarefa(1, 0, "Seg", "08:00", "23:00");
				Assert.Fail();
			} catch (ArgumentException ae) {
				Assert.AreEqual(ae.Message, "Pontuação de tarefa inválida");
			}
		}

		[Test]
		public void Valida_Tarefa_Codigo_CinquentaeUm() {

			try {
				Tarefa t = new Tarefa(1, 51, "Seg", "08:00", "23:00");
				Assert.Fail();
			} catch (ArgumentException ae) {
				Assert.AreEqual(ae.Message, "Pontuação de tarefa inválida");
			}
		}

		[Test]
		public void Valida_Tarefa_Pontos_Um() {

			try {
				Tarefa t = new Tarefa(1, 1, "Seg", "08:00", "23:00");
				Assert.AreEqual(1, t.Pontos);
			} catch (ArgumentException ae) {
				Assert.Fail();
			}
		}

		[Test]
		public void Valida_Tarefa_Pontos_Cinquenta() {

			try {
				Tarefa t = new Tarefa(1, 50, "Seg", "08:00", "23:00");
				Assert.AreEqual(50, t.Pontos);
			} catch (ArgumentException ae) {
				Assert.Fail();
			}
		}
		#endregion

		#region Valida Dias
		[TestCase("Seg")]
		[TestCase("TER")]
		[TestCase("QUa")]
		[TestCase("qui")]
		[TestCase("seX")]
		public void Valida_Tarefa_Dias_Semana_Validos(string dia) {

			try {
				Tarefa t = new Tarefa(1, 10, dia, "08:00", "23:00");
				Assert.Pass(t.Dia.ToString());
			} catch (ArgumentException ae) {
				Assert.Fail();
			}
		}

		[TestCase("Segunda")]
		[TestCase("Sab")]
		[TestCase("DOM")]
		[TestCase("Q")]
		[TestCase("T")]
		[TestCase("2")]
		[TestCase("Sexta")]
		[TestCase("3º feira")]
		public void Valida_Tarefa_Dias_Semana_Invalidos(string dia) {

			try {
				Tarefa t = new Tarefa(1, 10, dia, "08:00", "23:00");
				Assert.Fail();
			} catch (ArgumentException ae) {
				Assert.AreEqual("Dia da semana inválido", ae.Message);
			}
		}

		#endregion

		#region Valida Horarios
		[TestCase("00:01", "23:00")]
		[TestCase("09:00", "23:59")]
		[TestCase("00:00", "01:00")]
		[TestCase("00:30", "23:00")]
		[TestCase("08:00", "22:30")]
		public void Valida_Tarefa_Horarios_Validos(string inicio, string fim) {

			try {
				Tarefa t = new Tarefa(1, 10, "Seg", inicio, fim);
				Assert.Pass(t.HoraInicio.ToString("HH:mm") + " - " + t.HoraFim.ToString("HH:mm"));
			} catch (ArgumentException ae) {
				Assert.Fail();
			}
		}

		[TestCase("8:00", "23:00")]
		[TestCase("09:00", "24:00")]
		[TestCase("00:00", "25:00")]
		[TestCase("0", "23:00")]
		[TestCase("08:00", "a")]
		[TestCase("08:00", "15:1")]
		[TestCase("0800", "2100")]
		[TestCase("08.00", "21.00")]
		[TestCase("08 00", "21 00")]
		[TestCase("08-00", "21-00")]
		public void Valida_Tarefa_Horarios_Invalidos(string inicio, string fim) {

			try {
				Tarefa t = new Tarefa(1, 10, "Seg", inicio, fim);
				Assert.Fail();
			} catch (ArgumentException ae) {
				Assert.AreEqual("Hora inválida. Formato HH:MM", ae.Message);
			}
		}

		#endregion



		[SetUp]
		public void Init() {

		}

		[TearDown]
		public void Finalize() {
			
		}
	}
}
